<?php if(isset($isInsert) && $isInsert){
?>
<script>
	ajax('listContent','<?php echo $this->params['controller']?>/lists');
	closeBox('addContent','mainContent');
</script>
<?php
}
else{
?>
<div id="noContent"></div>
<fieldset>
    <legend><?php echo $page;?>
    <?php if($webConfig['is_multi_lang']){?>
    	<img class="Tips1" title="<?php echo $listLang[$locale]?>" border="0" src="<?php echo $this->webroot.'img/backend/flag/'.$locale.'.png'?>">
    <?php }?>
    </legend>
<center><div id="message" >&nbsp;</div><center>
<?php if($this->Session->read('message')){
	echo '<script>showMessage("addContent","'.$this->Session->read('message').'");</script>';
	$this->Session->delete('message');	
	}?>
<?php if($this->Session->read('error')){
	echo '<script>showMessage("addContent","'.$this->Session->read('error').'",1);</script>';
	$this->Session->delete('error');
}?>
    <form id="adminForm" name="adminForm" method="post" action="<?php echo $this->params['controller'].'/resource/'.$id.'/'.$locale ?>" onsubmit="onFormSubmit();return false;">
    
	<table id="tblResource" border="0" class="form" style="width:100%">
	<?php
			if(count($data)>0){
				$noresourceid=0;
			foreach($data as $k=>$v){
				if(empty($v[$uses[3]]['id'])){
					$v[$uses[3]]['id']=$noresourceid;
					$noresourceid--;
				}
		?>
	
       	<tr id="<?php echo $uses[2].$v[$uses[2]]['id']?>">          
       		<td class="label" align="right" width="300px"><?php echo $v[$uses[2]]['name'] ?></td>
       		<td align="left" width="500px">
       			<?php echo $this->Form->input($uses[3].'.'.$v[$uses[3]]['id'].'.resource_id',array('type'=>'hidden','default'=>$v[$uses[2]]['id'],'class'=>'input','label'=>'','style'=>'width:500px','maxlength'=>255));?>
       			<?php echo $this->Form->input($uses[3].'.'.$v[$uses[3]]['id'].'.message',array('default'=>$v[$uses[3]]['message'],'class'=>'input','label'=>'','style'=>'width:500px','maxlength'=>255));?>
       		</td>
       		<td align="left"><span title="<?php _resource('delete');?>"><a href="javascript:;" onclick="remove('<?php echo $uses[2].$v[$uses[2]]['id']?>',<?php echo $v[$uses[2]]['id']?>)"> <img border="0" src="<?php echo $this->webroot; ?>img/backend/16-square-red-remove.png"/></a></span></td>           
        </tr>  
        
        <?php } ?>
      <?php } ?>
        
     

 	
        
            
	</table>
    <div style="width:130px">
    	  <div class="button"><a href="javascript:;" onclick="add();"  > <span class="icon-32-new"> </span></a></div>
          <div class="button"><a onclick="onFormSubmit();" href="javascript:;" title="<?php echo _resource('save') ?>"  > <span class="icon-32-save"> </span></a> </div>          
          <div class="button"><a onclick="closeBox('addContent','mainContent')" href="javascript:;" title="<?php echo _resource('close') ?>"  > <span class="icon-32-cancel"> </span></a> </div>
    </div>
      </form>
</fieldset>
<script>
var newi=0;
function onFormSubmit(){
	submitForm('adminForm','addContent');
}	
scrollTopTo('addContent');	

function remove(div,id){
	$('#'+div).remove();
	if(id>0){
		ajax('noContent','<?php echo $this->params['controller'].'/delete_resource/'?>'+id);
	}
}

function add(){
	
	newi++;
	var ele='<tr id="ResourceNew'+newi+'">';	          
	ele+='	<td align="right" width="300px" class="label"><div class="input text"><input type="text" id="ResourceDetail21Message" value="" maxlength="255" style="width: 300px; text-align: right;" class="input" name="data[ResourceNew]['+newi+'][name]"></div></td>';
	ele+='	<td align="left" width="500px"><div class="input text"><input type="text" id="ResourceDetail21Message" value="" maxlength="255" style="width: 500px;" class="input" name="data[ResourceNew]['+newi+'][message]"></div></td>';
	ele+='	<td align="left"><span title="delete"><a onclick="remove(\'ResourceNew'+newi+'\','+newi+')" href="javascript:;"> <img border="0" src="/scyclub/img/backend/16-square-red-remove.png"></a></span></td>';           
	ele+='</tr>';
	
	$('#tblResource').append(ele);
}
</script>

<?php echo $this->element('sql_dump'); }?>